<?php

namespace app\common\model;

use think\Model;

class Follows extends Model
{
    //
    protected $autoWriteTimestamp=true;

    //关注的用户信息
    public function fUser(){
        return $this->hasOne('Users','uid','followed_user');
    }

    //关注的用户的关注信息[计数]
    public function fUserF(){
        return $this->hasMany('Follows','user_id','followed_user')->where('status',1);
    }

    //关注的用户的文章信息[计数]
    public function fPosts(){
        return $this->hasMany('BgPosts','uid','followed_user')->where('status',1);
    }

    //关注的用户的粉丝信息[计数]
    public function fUserFans(){
        return $this->hasMany('Fans','user_id','followed_user');
    }

    //是否session['uid']关注了此页面用户关注的用户
    public function hasFollow(){
        return $this->hasMany('Fans','user_id','followed_user')->where('fan_id',session('uid'));
    }
}
